package com.hc.daoimp;

import java.sql.SQLException;

import com.hc.dao.UserDao;
import com.hc.entity.User;
import com.hc.util.JDBCUtil;

public class UserDaoImpl implements UserDao{

	@Override
	public User getUser(String username, String password) {
		User user = new User();
		JDBCUtil.sql="SELECT * FROM `user` WHERE uname=? AND upassword=?";
		JDBCUtil.ps=JDBCUtil.getPs();
		try {
			JDBCUtil.ps.setString(1, username);
			JDBCUtil.ps.setString(2, password);
			JDBCUtil.rs=JDBCUtil.ps.executeQuery();
			while(JDBCUtil.rs.next()){
				user.setUname(JDBCUtil.rs.getString(2));
				user.setUpassword(JDBCUtil.rs.getString(3));
				
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return user;
	}

}
